// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Author: Markus Gutschke

#ifndef XMPP_H__
#define XMPP_H__

#include "connection.h"
#include "json.h"
#include "oauth2.h"
#include "xml.h"


struct XMPP {
  struct OAuth2     *oauth2;
  char              *server;
  char              *jid;
  char              *fulljid;
  char              *printerId;
  char              *printerDesc;
  char              *id;
  struct Connection *conn;
  struct XML        xml;
  unsigned          completed:1;
  unsigned          negotiateSSL:1;
  unsigned          restartStream:1;
  unsigned          ping;
};

struct XMPP *newXMPP(struct OAuth2 *oauth2, const char *jid,
                     const char *printerId, const char *printerDesc);
void initXMPP(struct XMPP *xmpp, struct OAuth2 *oauth2, const char *jid,
              const char *printerId, const char *printerDesc);
void destroyXMPP(struct XMPP *xmpp);
void deleteXMPP(struct XMPP *xmpp);
int handleXmppPacket(struct XMPP *xmpp, int (*fnc)(struct XML *xml,
                       struct XMLElement *elem, void *arg), void *arg);
int tickleXmpp(struct XMPP *xmpp);

#endif  // XMPP_H__
